package com.ruoyi.camp.service.impl;

import java.util.List;

import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.camp.mapper.CActivityMapper;
import com.ruoyi.camp.domain.CActivity;
import com.ruoyi.camp.service.ICActivityService;

/**
 * 营地活动Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-10-29
 */
@Service
public class CActivityServiceImpl implements ICActivityService 
{
    @Autowired
    private CActivityMapper cActivityMapper;

    /**
     * 查询营地活动
     * 
     * @param activityid 营地活动主键
     * @return 营地活动
     */
    @Override
    public CActivity selectCActivityByActivityid(String activityid)
    {
        return cActivityMapper.selectCActivityByActivityid(activityid);
    }

    /**
     * 查询营地活动列表
     * 
     * @param cActivity 营地活动
     * @return 营地活动
     */
    @Override
    public List<CActivity> selectCActivityList(CActivity cActivity)
    {
        return cActivityMapper.selectCActivityList(cActivity);
    }

    /**
     * 新增营地活动
     * 
     * @param cActivity 营地活动
     * @return 结果
     */
    @Override
    public int insertCActivity(CActivity cActivity)
    {
        cActivity.setActivityid(IdUtils.randomUUID());
        cActivity.setApprove("0");
        return cActivityMapper.insertCActivity(cActivity);
    }

    /**
     * 修改营地活动
     * 
     * @param cActivity 营地活动
     * @return 结果
     */
    @Override
    public int updateCActivity(CActivity cActivity)
    {
        return cActivityMapper.updateCActivity(cActivity);
    }

    /**
     * 批量删除营地活动
     * 
     * @param activityids 需要删除的营地活动主键
     * @return 结果
     */
    @Override
    public int deleteCActivityByActivityids(String[] activityids)
    {
        return cActivityMapper.deleteCActivityByActivityids(activityids);
    }

    /**
     * 删除营地活动信息
     * 
     * @param activityid 营地活动主键
     * @return 结果
     */
    @Override
    public int deleteCActivityByActivityid(String activityid)
    {
        return cActivityMapper.deleteCActivityByActivityid(activityid);
    }
    /**
     * 根据营地Id查询该营地的所有活动
     * @param campId 营地Id
     * @return 该营地的活动列表
     */
    @Override
    public List<CActivity> getInfoByCampId(String campId) {
        //封装条件
        CActivity activity = new CActivity();
        activity.setCampid(campId);
        activity.setApprove("1");
        //根据营地Id获取营地下的活动列表
        List<CActivity> list  = cActivityMapper.selectCActivityList(activity);
        //数据类型转换
        if (list != null && list.size() > 0) {
            return list;
        }
        return null;
    }

    /**
     * 根据活动Id获取详细信息
     * @param activityid 活动Id
     * @return 活动对象
     */
    @Override
    public CActivity getInfo(String activityid) {
        //根据活动id查询对象
        CActivity activity = cActivityMapper.selectCActivityByActivityid(activityid);
        return activity;
    }

}
